package com.elitel.frame.base.service.impl;

import com.elitel.frame.base.service.CfgMoreJoinService;
import com.elitel.frame.main.dao.CfgMoreJoinMapper;
import com.elitel.frame.main.dao.SysPrjserviceMapper;
import com.elitel.frame.main.entity.CfgMoreJoin;
import com.elitel.frame.main.entity.SysPrjservice;
import com.rometools.rome.feed.rss.Guid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.UUID;

/**
 * com.elitel.frame.base.service.impl
 *
 * @since 1.0.0 2019-04-04 11:19
 */
@Service
public class CfgMoreJoinServiceImpl implements CfgMoreJoinService {

    @Autowired
    private CfgMoreJoinMapper cfgMoreJoinMapper;

    @Autowired
    private SysPrjserviceMapper sysPrjserviceMapper;


    @Override
    public int insertCfgMoreJoinService(String servertype,String pCode,CfgMoreJoin cfgMoreJoin) {

        SysPrjservice sysPrjservice =  new SysPrjservice();
        sysPrjservice.setGuid(UUID.randomUUID().toString());
        sysPrjservice.setPcode(pCode);
        sysPrjservice.setServicecode(cfgMoreJoin.getGuid());
        sysPrjservice.setServicetype(servertype);
        sysPrjservice.setCreatedate(new Date());

        sysPrjserviceMapper.insert(sysPrjservice);
        return cfgMoreJoinMapper.insert(cfgMoreJoin);
    }

    @Override
    public int updateMoreJoinService(CfgMoreJoin cfgMoreJoin) {
        return cfgMoreJoinMapper.updateByPrimaryKey(cfgMoreJoin);
    }

    @Override
    public int deleteCfgMoreJoinService(String guid) {
        return cfgMoreJoinMapper.deleteByPrimaryKey(guid);
    }


    @Override
    public CfgMoreJoin getCfgMoreJoinByGuid(String guid) {
        return cfgMoreJoinMapper.selectByPrimaryKey(guid);
    }
}
